<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = 
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";

String errMessage = "";
errMessage = (String)request.getAttribute("errMessage");
System.out.println("errMessage = " + errMessage);
//errMessage = (String)session.getAttribute("errMessage");
if(errMessage == null) errMessage = "";
%>

<!doctype html>
<html>
<head>

<title>用户登录...</title>
<script>
		function checkUserName(un) {
			var nameformat = /^[a-zA-Z\d]\w{3,13}[a-zA-Z\d]$/;   //正则表达式 
			if(!nameformat.test(un)) {		//nameformat.test(un)正则表达式 的匹配 
				//alert("NameErr");
				document.getElementById("usernameErr").innerHTML = 
				"<font color='red' size='-1'>用户名格式错误，请输入5-15位的字符！</font>";
				//form.username.focus(); 
				//document.getElement("username").focus();
				//form.username.select();
				return false;
			}  else {
				document.getElementById("usernameErr").innerHTML = "";
				return true;
			}
		}
		
		function checkPassWord(psw) {
			var passwordformat = /^[a-z A-Z\d]\w{3,13}[a-z A-Z\d]$/;
			if(!passwordformat.test(psw)) {
				document.getElementById("passwordErr").innerHTML = "<font color='red' size='-1'>密码格式错误，请输入5-15位的 字符！</font>";
				//form.password.focus();
				//form.password.select();
				//document.getElement("password").focus();
				return false;
			} else {
				document.getElementById("passwordErr").innerHTML = "";
			}
		}

</script>
</head>

<body>
	<form  method="post" name="form" action="userLogin">
    	<table align="center" border = "1" width = "300">
			<th colspan="2">用户登录</th>
			<input type="hidden" name="action" value="logined"/>
			<tr>
				<td width="20%">用户名:</td>
				<td width="80%"><input width="100%" type="text" name="username" onBlur="tt_checkUserName(this.value)">
					<span id="usernameErr"></span>
				</td>
			</tr>
			<tr>
				<td>密&nbsp;&nbsp;&nbsp;码:</td>
				<td><input type="password" name ="password" onBlur="tt_checkPassWord(this.value)">
					<span id="passwordErr"></span>
				</td>
			</tr>
            
            <tr>
				<td colspan = "2" align="center">
					<input type="submit" value="登录" >&nbsp;&nbsp;&nbsp; <input type="reset" value="重置">
				</td>
			</tr>
			<tr>
				<td colspan ="2" border="0" width="100%">
                    <font color="#FF0000" size="-1" alig="center">${errMsg}</font>
				</td>
			 </tr>
			 
			 
        </table>
    </form>
</body>
</html>
